package cn.cyh.quartz.jobs;

import cn.cyh.order.service.IAdoptOrderService;
import cn.cyh.quartz.constant.JobTypes;
import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Map;

public class MainJob implements Job{
    @Autowired
    private IAdoptOrderService adoptOrderService;


    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        JobDataMap jobDataMap = jobExecutionContext.getJobDetail().getJobDataMap();
        Map<String,Object> params = (Map<String, Object>) jobDataMap.get("params");
        String type = (String) params.get("type");// 根据不同type执行不同业务
        switch (type) {
            case JobTypes.PAY_OVER_TIME_ADOPT_ORDER:
                Long orderId = (Long) params.get("orderId");
                adoptOrderService.deleteByQuartz(orderId);
                break;
            default:
                break;

        }

    }

}
